using Game.Main.Model;
using UnityEngine;

namespace Game.Component
{
	public class DoubleDoorCabinetItem : ContainerItem
	{
		private BoxCollider2D leftDoorBox;

		private BoxCollider2D rightDoorBox;

		private Transform openLeft;

		private Transform openRight;

		private Transform closeLeft;

		private Transform closeRight;

		public override void Init(ItemArchiveData data)
		{
			base.Init(data);
			BoxCollider2D[] components = model.GetComponents<BoxCollider2D>();
			if (components.Length > 1)
			{
				leftDoorBox = components[0];
				rightDoorBox = components[1];
			}
			else
			{
				Trace.LogError("双开门柜配置错误！");
			}
			openLeft = model.Find("OpenLeft");
			openRight = model.Find("OpenRight");
			closeLeft = model.Find("CloseLeft");
			closeRight = model.Find("CloseRight");
		}

		protected override void SetOpenColl()
		{
			BoxCollider2D component = openLeft.GetComponent<BoxCollider2D>();
			leftDoorBox.offset = component.offset;
			leftDoorBox.size = component.size;
			BoxCollider2D component2 = openRight.GetComponent<BoxCollider2D>();
			rightDoorBox.offset = component2.offset;
			rightDoorBox.size = component2.size;
		}

		protected override void SetCloseColl()
		{
			BoxCollider2D component = closeLeft.GetComponent<BoxCollider2D>();
			leftDoorBox.offset = component.offset;
			leftDoorBox.size = component.size;
			BoxCollider2D component2 = closeRight.GetComponent<BoxCollider2D>();
			rightDoorBox.offset = component2.offset;
			rightDoorBox.size = component2.size;
		}
	}
}
